// pages/goods/taskInfo/index.js
var app = getApp();
const util = require('../../../utils/util');
Page({

    /**
     * 页面的初始数据
     */
    data: {
        parameter: {
            'navbar': '1',
            'return': '1',
            'title': '任务详情',
            'color': true,
            'class': false
        },
        indicatorDots: true,
        vertical: false,
        autoplay: false,
        interval: 2000,
        duration: 500,
        executorUserId: "", //工蜂id
        pic: "https://pic.localhost.com/",
        nullImage: '/images/preview.png',
        dealerId: "", //店铺id
        goodsId: "" //商品id
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        var that = this;
        wx.getStorage({
            key: 'userInfo',
            success(res) {
                that.setData({
                    executorUserId: res.data.id,
                })
                that.orderInfo(options)
            }
        })
    },
    imageLoad: function (e) {
        this.setData({
            imageWidth: e.detail.width, //图片宽度自适应
            indicatorDots: true, //指示点
            vertical: false,
            autoplay: false,
            interval: 2000,
            duration: 500,
            previousMargin: 0,
            nextMargin: 0
        })
    },
    //任务执行铺货
    orderInfo(options) {
        var that = this;
        app.baseGet(app.U({
            m: 'api',
            c: 'task',
            a: 'worker/distribution/getOrder',
            q: {
                goodsId: options.goodsId,
                dealerId: options.dealerId,
                userId: that.data.executorUserId
            }
        }), res => {
            that.setData({
                orderinfo: res.data,
                status: res.data.status,
                dealer: res.data.dealer,
                goods: res.data.goods
            })
        }, (res) => {})
    }
})